import zgEngine from 'zego-express-engine-electron/ZegoExpressEngine'
import zgDefines from 'zego-express-engine-electron/ZegoExpressDefines'



class CallUtil {

  static {
    // 采用通用场景
    const profile = {
      appID : 1841309306,
      appSign : "87673f9fa9f9d1eb8001642bc5986f7dc146359b6b0b9a006ec1f6940cb00cf4",
      scenario : zgDefines.ZegoScenario.Default
    };

    zgEngine.createEngine(profile)
      .then(() => {
        console.log("init succeed")
      }).catch((e) => {
      console.log("init failed", e)
    });

// 以下为常用的房间相关回调
// 房间状态更新回调
    zgEngine.on("onRoomStateUpdate", this.onRoomStateUpdate);

// 用户状态更新回调
    zgEngine.on("onRoomUserUpdate", (param)=>{
      // 根据需要实现事件回调
      console.log('用户状态更新回调:' , param)
    });

// 流状态更新回调
    zgEngine.on("onRoomStreamUpdate", (param)=>{
      // 根据需要实现事件回调
      console.log('流状态更新回调:' , param)
    });
  }


  static isCalling = false;

  static onRoomStateUpdate (param) {}


  static startCall(roomId , userId , userName, config , callback) {
    zgEngine.on("onRoomStateUpdate", callback);  // 直接绑定传入的 callback
    zgEngine.loginRoom(roomId, {userID: userId , userName: userName} ,config)


  }

}


export default CallUtil;
